<template>
	<view class="user">
		<!-- 头部背景图 -->
		<view class="bg-img">
			<u-image widht="750rpx" height="217rpx" src="@/static/image/home/data_statistics/bg.png"></u-image>
		</view>
		<!-- 用户信息 -->
		<view class="user-wrap">
			<view class="user-info">
				<view class="user-avatar">
					<u-image width="130rpx" height="130rpx" shape="circle" :src="avatar"></u-image>
					<!-- <open-data type="userAvatarUrl"></open-data> -->
				</view>
				<view class="user-name" v-if="name">
					{{name}}
					<!-- <open-data type="userNickName"></open-data> -->
				</view>
				<view class="user-name" v-else @click="toHome">
					请登录
				</view>
			</view>
			<view class="identity">
				{{levelName}}
			</view>
		</view>
		<!-- 菜单列表 -->
		<view class="menu-list">
			<list-item v-for="(item, index) in menuList" :key="index" :item="item"></list-item>
		</view>
		<view style="position: absolute;bottom: 0;width: 100%;">
			<buttom-tip></buttom-tip>
		</view>
	</view>
</template>

<script>
	import ListItem from './components/list_item/ListItem.vue'
	import ButtomTip from '@/components/buttom_tip/ButtomTip.vue'
	export default {
		name: 'User',
		components: {
			ListItem,
			ButtomTip
		},
		data() {
			return {
				menuList: [{
						title: '个人信息',
						path: 'user_info'
					},
					{
						title: '审核设置',
						path: 'setting'
					},
					{
						title: '关于我们',
						path: 'about'
					}
				],
				level: '',
				levelName: '',
				avatar: '',
				name: '',
			}
		},
		onShow() {
			this.level = getApp().globalData.level;
			this.avatar = getApp().globalData.avatar;
			this.name = getApp().globalData.username;
			console.log(getApp().globalData)
		},
		onLoad() {
			this.levelName = getApp().globalData.levelName;
			if (this.levelName !== '部门领导') {
				this.menuList.splice(1, 1);
			}
		},
		methods: {
			toHome () {
				uni.switchTab({
					url: 'pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.user {
		padding: 30rpx 20rpx;
	}

	.bg-img {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		z-index: -1;
	}

	.user-wrap {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 40rpx 30rpx;
		width: 710rpx;
		height: 210rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 10rpx 20rpx 0rpx rgba(182, 216, 255, 0.4);
		border-radius: 20rpx;

		.user-info {
			display: flex;
			align-items: center;

			.user-avatar {
				width: 130rpx;
				height: 130rpx;
				border-radius: 50%;
			}

			.user-name {
				margin-left: 33rpx;
				font-size: 40rpx;
				font-weight: 500;
				color: #000000;
			}
		}

		.identity {
			width: 170rpx;
			height: 40rpx;
			font-size: 28rpx;
			color: #196EFF;
			line-height: 40rpx;
			text-align: center;
			background: #FFFFFF;
			border: 2rpx solid #196EFF;
			border-radius: 20rpx;
		}
	}

	.menu-list {
		margin-top: 30rpx;
		padding: 30rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 10rpx 20rpx 0rpx rgba(182, 216, 255, 0.4);
		border-radius: 20rpx;
	}
</style>
